package com.peanut.controller;

import com.peanut.common.Result;
import com.peanut.domain.ov.TabItemOV;
import com.peanut.dto.TabItemDTO;
import com.peanut.server.SubmitInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("sub")
@Api
public class SubmitInformationController {
    private Logger logger = LoggerFactory.getLogger(TabSeriesController.class);
    @Resource
    private SubmitInformationService submitInformationService;

    @ApiOperation("查询卖车信息")

    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键id", paramType = "path", dataTypeClass = Long.class),
    }
    )
    //查询卖车信息
    @PostMapping("tabCarSellInformationByIds/{id}")
    public Result tabCarSellInformationById(@PathVariable("id") Long id) {
        try {
            TabItemDTO tabItemDTO = submitInformationService.tabCarSellInformationById(id);
            TabItemOV tabItemOV = new TabItemOV();
            BeanUtils.copyProperties(tabItemOV, tabItemDTO);
            return Result.OK().setData(tabItemOV);
        } catch (Exception e) {
            logger.error("查询出错", e);
            return Result.ERROR();
        }

    }

}
